#include("/admin/common/header.html")
#include("/admin/common/footer.html")
#include("/admin/common/left.html")
#include("/admin/common/layout.html")
 
 #@layout()
 #define content()

<span class="layui-breadcrumb">
  <a href="#(ctx_path)/">首页</a>
  <a href="#(ctx_path)/admin/shop/member"><cite>用户管理</cite></a>
</span>

<hr>


<div class="layui-field-box">
<form class="layui-form" action="#(ctx_path)/admin/shop/member" id="searchForm">
    <div class="layui-form-item">
    		<div class="layui-inline">
	      <label class="layui-form-label">搜索内容</label>
	      <div class="layui-input-inline">
	        <input type="text" name="searchContent" autocomplete="off" class="layui-input" placeholder="请输入内容搜索">
	      </div>
	    </div>
	    
	    <div class="layui-inline">
	      <label class="layui-form-label">状态</label>
	      <div class="layui-input-inline">
	      		#set(DIC_MAP={})
	      		#set(DIC_MAP["dicTypeCode"]="USER_STATUS")
	      		#set(DIC_MAP["name"]="status")
	      	   	#set(DIC_MAP["id"]="status")
	        	#@dic_get_select(DIC_MAP)
	      </div>
	    </div>
	    
	    <button class="layui-btn" type="button" id="btnSearch">搜索</button>
	    <button class="layui-btn layui-btn-normal" type="reset" >重置</button>
	    #auth('USER_ADD')
			<a class="layui-btn layui-btn-danger" href="#(ctx_path)/admin/shop/member/add" >新增</a>
		#end
	   
	    
	</div>
</form>	    
</div>
  
<table class="layui-hide" id="dataTable"></table>


<script type="text/html" id="actionTpl">

  	<a href="javascript:doDetail('{{d.id}}');" class="layui-table-link" actionType="detail" actionId="{{d.id}}">详情</a>
  	<a href="javascript:doStartUsing('{{d.id}}');" class="layui-table-link" >启用</a>
  	<a href="javascript:doForbidden('{{d.id}}');" class="layui-table-link" >禁用</a>
	
	#auth('user')
		<a href="javascript:doDelete('{{d.id}}');" class="layui-table-link">删除</a>
	#end
</script>

#end

#define js()

<script>


	layui.use('table', function() {
		
		var table = layui.table;
		table.render({
			elem : '#dataTable',
			url : '#(ctx_path)/admin/shop/member/pagequery',
			cols : [ [
		      {field:'nickname', title: '姓名'},
		      {field:'email', title: '邮箱'},
		      {field:'cellphone', title: '手机'},
		      {field:'createTime', title: '创建时间'},
		      {field:'status_dic', title: '状态'},
		      {templet:"#actionTpl",width:'150',title: '操作'}
			] ],
			page : true
		});
		
		$("#btnSearch").click(function(){
			
			var searchContent=$(":input[name='searchContent']").val();
			var status=$(":input[name='status']").val();
			
			//执行重载
			table.reload('dataTable', {
				page : {
					curr : 1//重新从第 1 页开始
				},
				where : {
					searchContent:searchContent,
					status:status
				}
			});
			
		});

	});

	function doDetail(id) {
		window.location.href = "#(ctx_path)/admin/shop/member/view?id=" + id;
	}

	function doStartUsing(id) {
		layui.layer.confirm('确认启用么?', function(index) {
			$.ajax({
				type : 'get',
				url : '#(ctx_path)/admin/shop/member/startUsing',
				data : 'id=' + id,
				success : function(data) {
					layui.table.reload('dataTable');
				}
			});
			layui.layer.close(index);
		});
	}

	function doForbidden(id) {
		layui.layer.confirm('确认禁用么?', function(index) {
			$.ajax({
				type : 'get',
				url : '#(ctx_path)/admin/shop/member/forbidden',
				data : 'id=' + id,
				success : function(data) {
					layui.table.reload('dataTable');
				}
			});
			layui.layer.close(index);
		});
	}

	function doDelete(id) {
		layui.layer.confirm('确认删除么?', function(index) {
			$.ajax({
				type : 'get',
				url : '#(ctx_path)/admin/shop/member/delete',
				data : 'id=' + id,
				success : function(data) {
					layui.table.reload('dataTable');
				}
			});
			layui.layer.close(index);
		});
	}
</script>

#end


